Skip to main content

Create and delete File/ Directory in Linux:

 

Command

Description

touch

Create a 0 bytes file

cat > filename

Create a file and allow to write (ctrl+c) to exit

Override

cat >> filename

Add content to the existing file

Appending

vi

Create a file if doesn’t exist and add the content in the vi editor

rm

Remove a file

Ex: rm filename

rm -f

Remove a file forcefully

Ex: rm -f filename

mkdir

Create a Directory

rmdir

Remove a empty directory

rm -rf

Remove a directory forcefully

Ex: rm -rf dir

ls -l

Long Listing (In Alphabetic order)

ls -lt

Display depends upon the time (Latest)

ls -ltr

Recursive for the above command

ls -la

Show hidden files

tree

Shows tree of a Directory

rm -rf *

Delete all directories and files in a current path. Please be careful while executing this command. It’s a permanent delete

 

Comments